{extend name="base" /}
{block name="body"}

<div class="am-padding am-padding-bottom-0">
	<strong class="am-text-primary am-text-lg">栏目管理</strong> / <small>Category</small>
</div>

<div class="am-padding am-btn-toolbar">
	<div class="am-btn-group am-btn-group-xs">
		<a href="{:url('admin/Category/index')}" class="am-btn am-btn-default"><span class="am-icon-plus"></span> 列表</a>
		<a href="{:url('admin/Category/add')}" class="am-btn am-btn-default"><span class="am-icon-plus"></span> 新增</a>
	</div>
</div>

<div class="am-padding am-scrollable-horizontal">
	<table class="am-table am-table-bd am-table-striped am-text-nowrap admin-content-table">
		<thead>
			<tr>
				<th>ID</th>
				<th>名称</th>
				<th>目录</th>
				<th>导航</th>
				<th>排序</th>
				<th>状态</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			{foreach name="category_list_tree" item="vo"}
			<tr>
				<td class="am-text-middle">{$vo.id}</td>
				<td class="am-text-middle">{$vo.title}</td>
				<td class="am-text-middle">{$vo.name}</td>
				<td class="am-text-middle">
					{eq name="$vo.is_menu" value="1"}
						<a href="{:url('admin/category/setStatus',['id'=>$vo.id,'is_menu'=>0])}" data-param="" class="am-icon-toggle-on am-text-success ajax-get" title="设置：不显示"></a>
					{else/}
						<a href="{:url('admin/category/setStatus',['id'=>$vo.id,'is_menu'=>1])}" data-param="" class="am-icon-toggle-off am-text-danger ajax-get" title="设置：显示"></a>
					{/eq}
				</td>
				<td class="am-text-middle"><input type="number" class="am-form-field ipt-sort" data-id="{$vo['id']}" value="{$vo.sort}"></td>
				<td class="am-text-middle">
					{eq name="$vo.status" value="1"}
						<a href="{:url('admin/category/setStatus',['id'=>$vo.id,'status'=>0])}" data-param="" class="am-icon-toggle-on am-text-success ajax-get" title="设置：不显示"></a>
					{else/}
						<a href="{:url('admin/category/setStatus',['id'=>$vo.id,'status'=>1])}" data-param="" class="am-icon-toggle-off am-text-danger ajax-get" title="设置：显示"></a>
					{/eq}
				</td>
				<td class="am-text-middle">
					<div class="am-btn-toolbar">
						<div class="am-btn-group am-btn-group-xs">
							<a href="{:url('admin/Category/edit',['id'=>$vo['id']])}" class="am-btn am-btn-default am-btn-xs am-text-secondary"><span class="am-icon-pencil-square-o"></span> 编辑</a>
							<a href="{:url('admin/Category/delete',['id'=>$vo['id']])}" class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only ajax-delete"><span class="am-icon-trash-o"></span> 删除</a>
						</div>
					</div>
				</td>
				
			</tr>
			{/foreach}

		</tbody>
	</table>
</div>

{/block}


{block name="script"}
<script>
$(".ipt-sort").blur(function(){

	$(this).css("background-color","#eee");

	var loading = layer.load(0, {
		shade: false
	});

	var _href = "{:url('admin/category/setStatus')}";
	
	var id = $(this).data('id');
	var sort = $(this).val();

	
	$.ajax({
		url: _href,
		type: "get",
		data: {'id':id, 'sort':sort},
		success: function(info) {
			layer.close(loading);
		
			if (info.code === 1) {
				layer.msg(info.msg);
			} else {
				layer.msg(info.msg);
			}
		
		}
	});
	return false;

});
</script>
{/block}